<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>退款申请API测试</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }
        .test-section {
            margin: 20px 0;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
        button {
            background: #007bff;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            margin: 5px;
        }
        button:hover {
            background: #0056b3;
        }
        .result {
            margin-top: 10px;
            padding: 10px;
            background: #f8f9fa;
            border-radius: 5px;
            white-space: pre-wrap;
        }
        .error {
            background: #f8d7da;
            color: #721c24;
        }
        .success {
            background: #d4edda;
            color: #155724;
        }
    </style>
</head>
<body>
    <h1>退款申请API测试</h1>
    
    <div class="test-section">
        <h3>测试退款申请列表API</h3>
        <button onclick="testRefundList()">获取退款申请列表</button>
        <div id="refundListResult" class="result"></div>
    </div>

    <div class="test-section">
        <h3>测试退款申请详情API</h3>
        <input type="number" id="refundId" placeholder="输入退款申请ID" value="1">
        <button onclick="testRefundDetail()">获取退款申请详情</button>
        <div id="refundDetailResult" class="result"></div>
    </div>

    <div class="test-section">
        <h3>测试退款申请统计API</h3>
        <button onclick="testRefundStatistics()">获取退款申请统计</button>
        <div id="refundStatisticsResult" class="result"></div>
    </div>

    <script>
        async function testRefundList() {
            const resultDiv = document.getElementById('refundListResult');
            resultDiv.textContent = '正在请求...';
            resultDiv.className = 'result';
            
            try {
                const response = await fetch('/api/RefundApplication/list?pageIndex=1&pageSize=5');
                const data = await response.json();
                
                resultDiv.textContent = JSON.stringify(data, null, 2);
                resultDiv.className = data.success ? 'result success' : 'result error';
            } catch (error) {
                resultDiv.textContent = '请求失败: ' + error.message;
                resultDiv.className = 'result error';
            }
        }

        async function testRefundDetail() {
            const resultDiv = document.getElementById('refundDetailResult');
            const id = document.getElementById('refundId').value;
            
            if (!id) {
                resultDiv.textContent = '请输入退款申请ID';
                resultDiv.className = 'result error';
                return;
            }
            
            resultDiv.textContent = '正在请求...';
            resultDiv.className = 'result';
            
            try {
                const response = await fetch(`/api/RefundApplication/detail/${id}`);
                const data = await response.json();
                
                resultDiv.textContent = JSON.stringify(data, null, 2);
                resultDiv.className = data.success ? 'result success' : 'result error';
            } catch (error) {
                resultDiv.textContent = '请求失败: ' + error.message;
                resultDiv.className = 'result error';
            }
        }

        async function testRefundStatistics() {
            const resultDiv = document.getElementById('refundStatisticsResult');
            resultDiv.textContent = '正在请求...';
            resultDiv.className = 'result';
            
            try {
                const response = await fetch('/api/RefundApplication/statistics');
                const data = await response.json();
                
                resultDiv.textContent = JSON.stringify(data, null, 2);
                resultDiv.className = data.success ? 'result success' : 'result error';
            } catch (error) {
                resultDiv.textContent = '请求失败: ' + error.message;
                resultDiv.className = 'result error';
            }
        }
    </script>
</body>
</html> 